/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.anniversary.rest;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.AnonymousAccess;
import me.zhengjie.annotation.Log;
import me.zhengjie.modules.anniversary.service.StatisticsInfoService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* @website https://el-admin.vip
* @author Jiayin Wei
* @date 2020-07-27
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "统计信息")
@RequestMapping("/api/statistics")
public class StatisticsInfoController {

    private final StatisticsInfoService statisticsInfoService;

    @GetMapping(value = "/gender")
    @Log("查询学生校友性别分布")
    @ApiOperation("查询学生校友性别分布")
    @AnonymousAccess
    public ResponseEntity<Object> gender(String college){
        return new ResponseEntity<>(statisticsInfoService.gender(college),HttpStatus.OK);
    }

    @GetMapping(value = "/nation")
    @Log("查询学生校友民族分布")
    @ApiOperation("查询学生校友民族分布")
    @AnonymousAccess
    public ResponseEntity<Object> nation(String college, Integer top){
        return new ResponseEntity<>(statisticsInfoService.nation(college, top),HttpStatus.OK);
    }

    @GetMapping(value = "/political")
    @Log("查询学生校友政治面貌分布")
    @ApiOperation("查询学生校友政治面貌分布")
    @AnonymousAccess
    public ResponseEntity<Object> political(String college, Integer top){
        return new ResponseEntity<>(statisticsInfoService.political(college, top),HttpStatus.OK);
    }

    @GetMapping(value = "/teacher/gender")
    @Log("查询教师校友性别分布")
    @ApiOperation("查询教师校友性别分布")
    @AnonymousAccess
    public ResponseEntity<Object> genderTeacher(){
        return new ResponseEntity<>(statisticsInfoService.genderTeacher(),HttpStatus.OK);
    }

    @GetMapping(value = "/teacher/nation")
    @Log("查询教师校友民族分布")
    @ApiOperation("查询教师校友民族分布")
    @AnonymousAccess
    public ResponseEntity<Object> nationTeacher(Integer top){
        return new ResponseEntity<>(statisticsInfoService.nationTeacher(top),HttpStatus.OK);
    }

    @GetMapping(value = "/teacher/political")
    @Log("查询教师校友政治面貌分布")
    @ApiOperation("查询教师校友政治面貌分布")
    @AnonymousAccess
    public ResponseEntity<Object> politicalTeacher(Integer top){
        return new ResponseEntity<>(statisticsInfoService.politicalTeacher(top),HttpStatus.OK);
    }

    @GetMapping(value = "/teacher/industry")
    @Log("查询教师校友行业分布")
    @ApiOperation("查询教师校友行业分布")
    @AnonymousAccess
    public ResponseEntity<Object> industryTeacher(Integer top){
        return new ResponseEntity<>(statisticsInfoService.industryTeacher(top),HttpStatus.OK);
    }

    @GetMapping(value = "/teacher/dept")
    @Log("查询各学院教师校友分布")
    @ApiOperation("查询各学院教师校友分布")
    @AnonymousAccess
    public ResponseEntity<Object> deptTeacher(Integer top){
        return new ResponseEntity<>(statisticsInfoService.deptTeacher(top),HttpStatus.OK);
    }

    @GetMapping(value = "/stuTeacherIncreased")
    @ApiOperation("查询近 num 学生和教师校友新增数统计")
    public ResponseEntity<Object> stuTeacherIncreased(Integer num){
        return new ResponseEntity<>(statisticsInfoService.stuTeacherIncreased(num),HttpStatus.OK);
    }
}
